﻿#ifndef IDATITLE_H
#define IDATITLE_H

#include <QToolBar>
#include "IdaPara.h"

class TitleBarPrivate;

class IdaTitleBar : public QToolBar
{
    Q_OBJECT
public:
    explicit IdaTitleBar(QWidget* parent = Q_NULLPTR);
    ~IdaTitleBar();

    /// @brief 设置窗体按钮
    /// @param type 按钮类型
    void setWindowButtonType(BaseWidget::ETitleBars type);

    /// @brief 获取窗体按钮类型
    /// @return 
    BaseWidget::ETitleBars getWindowButtonType();

    void setIsMainWindow(bool isMainWindow);

    void setHeight(int height);

    void setTitleFontSize(int size);

    void setInitializationWindowMaximization();

    void setIcon(const QIcon& icon);

signals:

    /// @brief 窗体状态变化
    /// @param windowState 窗体状态
    void signal_windowStateChange(Qt::WindowStates windowState);

    /// @brief 窗体关闭按钮被点击
    void signal_closeButtonClick();


protected:

    /// @brief 被双击--标题栏被双击，放大还原
    /// @param event 鼠标双击事件
    virtual void mouseDoubleClickEvent(QMouseEvent* event);
    
    /// @brief 拖拽移动效果
    /// @param event 鼠标按下事件
    virtual void mousePressEvent(QMouseEvent* event);
    
    /// @brief 鼠标抬起--拖拽移动效果
    /// @param event 鼠标释放事件
    virtual void mouseReleaseEvent(QMouseEvent* event);
    
    /// @brief 鼠标移动--拖拽移动效果
    /// @param event 鼠标移动事件
    virtual void mouseMoveEvent(QMouseEvent* event);
    
    /// @brief 事件过滤--修改标题、图标等操作
    /// @param obj 对象
    /// @param event 事件
    /// @return 
    virtual bool eventFilter(QObject* obj, QEvent* event);


private slots:
    
    /// @brief 最小化按钮被点击
    void slot_minimizeButtonClicked();

    /// @brief 最大化、还原按钮被点击
    void slot_maximizeButtonClicked();

    /// @brief 关闭按钮被点击
    void slot_closeButtonClicked();

    void changeWindowSize();

private:
    TitleBarPrivate* m_private{};
};

#endif // IDATITLE_H
